/******************************************************************************
*
* This file is part of FreeTrack (http://code.google.com/p/qtfreetrack).
* BY Willy Gardiol (willy@gardiol.org)
*
* FreeTrack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeTrack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar.  If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************/

#ifndef LAYERTRACKCONFIG_H
#define LAYERTRACKCONFIG_H

#include "IncFreeTrack.h"
#include "freetrackwidget.h"

class FTWidgetList;
class LayerTrack;
class OauthManager;
class FTHelpWidget;
class FTTabWidget;
class FTLabel;
class FTPushButton;


class LayerTrackConfig : public FreeTrackWidget
{
    Q_OBJECT
public:
    explicit LayerTrackConfig(QWidget*, LayerTrack*);
    ~LayerTrackConfig();

signals:

public slots:
    // Save slot (to update the layer)
    void updateTrack();
    // User wants to delete a waypoint
    void deleteWaypoint(int);

private slots:
    // open the color selection dialog
    void selectColor();
    // intercept tab change and prevent it if breadcrumbs is not authorized (show warning)
    void changeTab();
    // Operate breadcrumbs buttons
    void breadcrumbsExport();
    void breadcrumbsNewBundle();
    void breadcrumbsReloadActivities();
    // Load activities...
    void breadcrumbsLoadActivities(bool nested = false);
    // Connect to activities combo box
    void breadcrumbsSelectActivity(QString);

private:

    // Widgets
    FTPushButton* save_button;
    FTPushButton* cancel_button;
    FTTabWidget* tabs;

    // Tab setup
    QWidget* tab_setup;
    QLineEdit* title;
    FTLabel* title_label;
    QLineEdit* description;
    FTLabel* description_label;
    FTPushButton* color_button;
    FTLabel* color_label;
    QScrollBar* size_bar;

    // Tab waypoints
    QWidget* tab_waypoints;
    FTWidgetList* waypoints_list;
    QHash<int, QLineEdit*> waypoint_names;
    QHash<int, QLineEdit*> waypoint_descriptions;
    QList<int> deleted_waypoints;
    int n_waypoints;

    // Tab breadcrumbs
    QWidget* tab_breadcrumbs;
    QComboBox* breadcrumbs_activities;
    QComboBox* breadcrumbs_bundles;
    FTPushButton* breadcrumbs_reload_activities;
    FTPushButton* breadcrumbs_new_bundle;
    FTPushButton* breadcrumbs_export;
    FTLabel* breadcrumbs_activities_label;
    FTLabel* breadcrumbs_bundles_label;
    FTHelpWidget* breadcrumbs_help;

    void setColor( QColor );
    QColor color;

    LayerTrack* track;
    OauthManager* oauth;

    QLayout* createHorizontal();
    QLayout* createVertical();

};

#endif // LAYERTRACKCONFIG_H
